<?php
namespace app\admin\controller;

use app\admin\controller\Base;
use think\Db;
class Feedback extends Base
{
    /**
     * 反馈列表
     * @return mixed
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function FeedbackList(){
        //总记录条数
        $Count = FeedbackCount();
        $this->assign('Count',$Count);

        //公告列表
        $FeedbackList = FeedbackList();
        $this->assign('FeedbackList',$FeedbackList['FeedbackList']);

        //分页
        $this->assign('Page', $FeedbackList['Page']);

        return $this->fetch('FeedbackList');
    }

    /**
     * 反馈详情
     * @return array|mixed
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function FeedbackEdit(){
        //反馈详情
        $FeedbackInfo = FeedbackInfo(['id'=>Param('id')]);
        $this->assign('FeedbackInfo',$FeedbackInfo);

        //Post请求操作
        if(IsPost()){
            //请求数据
            $Data = Param();
            $Data['back_time'] = time();
            $Data['status'] = 1;
            //向表中添加数据
            if(Db::name('feedback')->update($Data)){
                return ['status'=>1,'message'=>'回复成功'];
            }else{
                return ['status'=>0,'message'=>'系统错误，请重试'];
            }
        }

        return $this->fetch('FeedbackEdit');
    }
}